﻿using System;
using System.Collections.Generic;
using System.Text;
using Galaxy.ModuleInterface;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting;

namespace Galaxy.Portal.Remoting
{
    /// <summary>Портал с использованием Remoting</summary>
    public class CRemotingPortal : CGalaxyPortalModule, IPortal, IGalaxyModule
    {
        /* -------------------------------------------------------------------------- */

        private TcpChannel f_Channel;

        /* -------------------------------------------------------------------------- */


        /* -------------------------------------------------------------------------- */

        public CRemotingPortal() : base("Портал Remoting") { }

        public CRemotingPortal(string Name)
            : base(Name) { }


        /* -------------------------------------------------------------------------- */


        public override void Initialize()
        {
            f_Channel = new TcpChannel(Port);
            ChannelServices.RegisterChannel(f_Channel, false);
        }

        public override void Start()
        {
            CRemotingConnector.AddPortal(this);
        }

        public override void Stop()
        {
            CRemotingConnector.RemovePortal(this);
        }

        /* -------------------------------------------------------------------------- */

        public override void SendMessage(Galaxy.ModuleInterface.Messages.IGalaxyModuleMessage Message)
        {
            
        }

        /* -------------------------------------------------------------------------- */
    }
}
